package com.zx.baofu.alcohol.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result {
    private int code;
    private String msg;
    private Object data;
    private Integer totalNum;
    private Integer totalPage;


    public Result success(String msg, Object data){
        this.code = 200;
        this.msg = msg;
        this.data = data;
        return this;
    }
    public Result success(String msg){
        this.code = 200;
        this.msg = msg;
        return this;
    }

    /**
     *
     * @param msg
     * @param data
     * @param totalNum
     * @param totalPage
     * @return
     */
    public Result success(String msg, Object data, int totalNum, int totalPage){
        this.code = 200;
        this.msg = msg;
        this.data = data;
        this.totalNum = totalNum;
        this.totalPage = totalPage;
        return this;
    }

    public Result fail(String msg){
        this.code = 500;
        this.msg = msg;
        return this;
    }
    public Result fail(String msg, Object data){
        this.code = 500;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public Result unPrize(String msg){
        this.code = 202;
        this.msg = msg;
        return this;
    }

}
